package com.abluedog.mixin;

import com.abluedog.event.PlayerConnectionCallBack;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ConnectedClientData;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(PlayerManager.class)
public abstract class PlayerManagerMixin {

    @Inject(at = @At("RETURN"), method = "onPlayerConnect",locals = LocalCapture.CAPTURE_FAILHARD)
    private void injectOnPlayerConnect(ClientConnection connection, ServerPlayerEntity player, ConnectedClientData clientData,CallbackInfo info) {
        PlayerConnectionCallBack.After.invoker().afterPlayerConnect(connection, player, clientData);
    }
}
